<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html xmlns:th="" lang="zh-CN">
<%@include file="/WEB-INF/pages/base/include.jsp"%>
<body>
<div id="wrapper">
    <%@include file="/WEB-INF/pages/base/menu.jsp"%>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header">消费管理</h3>
            </div>
        </div>
        <div class="row">
            <form class="form-horizontal" data-parsley-validate>
                <div class="col-lg-12 col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">消费基本信息</div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-12 col-md-12">
                                	<div class="form-group">
                                        <label class="col-lg-2 clo-md-2 control-label">商家ID：</label>
                                        <div class="col-lg-8">
                                            <input type="text" id="unionId" class="form-control" placeholder="请输入商家ID"
                                                   required>
                                        </div>
                                        <div class="col-lg-2 clo-md-2">
                                            <span class="help-block">*必须填写</span>
                                        </div>
                                    </div>
                                	<div class="form-group">
                                        <label class="col-lg-2 clo-md-2 control-label">用户ID：</label>
                                        <div class="col-lg-8">
                                            <input type="text" id="accountId" class="form-control" placeholder="请输入用户ID"
                                                   required>
                                        </div>
                                        <div class="col-lg-2 clo-md-2">
                                            <span class="help-block">*必须填写</span>
                                        </div>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label class="col-lg-2 clo-md-2 control-label">积分：</label>
                                        <div class="col-lg-8">
                                            <input type="text" id="useAccumulatePoints" class="form-control" placeholder="请修改积分"
                                                   required>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-lg-2 clo-md-2 control-label">金额：</label>
                                        <div class="col-lg-8">
                                            <input type="text" id="useMoney" class="form-control" placeholder="请输入金额"
                                                   required>
                                        </div>
                                        <div class="col-lg-2 clo-md-2">
                                            <span class="help-block">*必须填写</span>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-lg-2 clo-md-2 control-label">总金额：</label>
                                        <div class="col-lg-8">
                                            <input type="text" id="total" class="form-control" placeholder="请输入总金额"
                                                   required>
                                        </div>
                                        <div class="col-lg-2 clo-md-2">
                                            <span class="help-block">*必须填写</span>
                                        </div>
                                    </div>
                                    	
                                    
                                   
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="clearfix"></div>
                <button type="button" class="btn btn-primary" onclick="discuss_modify()"
                        style="margin-left:15px;margin-bottom:30px;">发布
                </button>
                <button class="btn btn-default" id="cancel" style="margin-left:15px;margin-bottom:30px;">
                    取消
                </button>
            </form>
        </div>
    </div>
</div>
<script>
	$(function(){
		var unionConsumeId = "${unionConsumeId}";
		var baseURL = "${webPath}/unionConsume/detail";
	  	var json_package = {
	       "head": {},
	       "body": {
	       	"id": unionConsumeId
	       }
	   	}
		$.post(baseURL, {"json_package": JSON.stringify(json_package)}, function (result) {
	      if (typeof result == 'string') result = JSON.parse(result);
	      if (result.body.result == '1') {
	          alert(result.body.description)
	      } else {
	      	var unionConsume = result.body.unionConsume;
	      	$("#unionId").val(unionConsume.unionId);	    
	      	$("#accountId").val(unionConsume.accountId);
	      	$("#useAccumulatePoints").val(unionConsume.useAccumulatePoints);
	      	$("#useMoney").val(unionConsume.useMoney);
	      	$("#total").val(unionConsume.total);
	      }
	  	})
	});
	
	function unionConsume_modify() {
		
    	var baseURL = "${webPath}/unionConsume/modify";
    	var unionConsumeId = "${unionConsumeId}";
    	var unionId = $('#unionId').val();
    	var accountId = $('#accountId').val();
     
        var useAccumulatePoints = $('#useAccumulatePoints').val();
        var useMoney = $('#useMoney').val();
        var total = $('#total').val();
        
       
        
        var json_package = {
       		"head": {},
            "body": {
            	"id":unionConsumeId,
            	"unionId": unionId,
            	"accountId": accountId,                
                "useAccumulatePoints": useAccumulatePoints,
                "useMoney": useMoney,
                "total": total,
                
            }
        };
        $.post(baseURL, {"json_package": JSON.stringify(json_package)}, function (result) {
            if (typeof result == 'string') result = JSON.parse(result);
            if (result.body.result == '0') {
                alert('修改成功！')
                window.location.reload(true);
            } else {
                alert('修改失败！')
            }
        })
    }
	$(function () {
        $('#cancel').click(function () {
            window.location.href = "${webPath}toUnionConsume";
        })
    });
	
	/* (function(){
		var ajaxUpload = new AjaxUpload($('#photoUpload_1'), {
		    action: '${webPath}/file/uploadImage',
		    data: {
		        "json_package": JSON.stringify({
		            "head": {},
		            "body": {"file": "file"}
		        })
		    },
		    name: 'file',
		    onSubmit: function (file, ext) {
		        window.uploading = true;
		        $('#photoUpload_1').text('上传中...');
		        $('#photoUpload_1').attr('disabled', true);
		        this.disable();
		
		    },
		    onChange: function (file, extension) {
		        this.disable();
		    },
		    onComplete: function (file, response) {
		    	var data = JSON.parse(response);

		    	var result = data.body.result;
				var description = data.body.description;
				if(result == "1"){
					alert("图片太大");
					window.uploading = false;
					this.enable();
					return;
				}
				
				var fileUrl = data.body.fileUrl;
				
		    	$("#image1").attr('src',fileUrl); 
		        window.uploading = false;
		        $('#photoUpload_1').text('上传图片');
		        this.enable();
		    }
		});
	})();
    (function(){
		var ajaxUpload = new AjaxUpload($('#photoUpload_2'), {
		    action: '${webPath}/file/uploadImage',
		    data: {
		        "json_package": JSON.stringify({
		            "head": {},
		            "body": {"file": "file"}
		        })
		    },
		    name: 'file',
		    onSubmit: function (file, ext) {
		        window.uploading = true;
		        $('#photoUpload_2').text('上传中...');
		        $('#photoUpload_2').attr('disabled', true);
		        this.disable();
		
		    },
		    onChange: function (file, extension) {
		        this.disable();
		    },
		    onComplete: function (file, response) {
		    	var data = JSON.parse(response);

		    	var result = data.body.result;
				var description = data.body.description;
				if(result == "1"){
					alert("图片太大");
					window.uploading = false;
					this.enable();
					return;
				}
				
				var fileUrl = data.body.fileUrl;
				
		    	$("#image2").attr('src',fileUrl); 
		        window.uploading = false;
		        $('#photoUpload_2').text('上传图片');
		        this.enable();
		    }
		});
	})();
    (function(){
		var ajaxUpload = new AjaxUpload($('#photoUpload_3'), {
		    action: '${webPath}/file/uploadImage',
		    data: {
		        "json_package": JSON.stringify({
		            "head": {},
		            "body": {"file": "file"}
		        })
		    },
		    name: 'file',
		    onSubmit: function (file, ext) {
		        window.uploading = true;
		        $('#photoUpload_3').text('上传中...');
		        $('#photoUpload_3').attr('disabled', true);
		        this.disable();
		
		    },
		    onChange: function (file, extension) {
		        this.disable();
		    },
		    onComplete: function (file, response) {
		    	var data = JSON.parse(response);

		    	var result = data.body.result;
				var description = data.body.description;
				if(result == "1"){
					alert("图片太大");
					window.uploading = false;
					this.enable();
					return;
				}
				
				var fileUrl = data.body.fileUrl;
				
		    	$("#image3").attr('src',fileUrl); 
		        window.uploading = false;
		        $('#photoUpload_3').text('上传图片');
		        this.enable();
		    }
		});
	})();
    (function(){
		var ajaxUpload = new AjaxUpload($('#photoUpload_4'), {
		    action: '${webPath}/file/uploadImage',
		    data: {
		        "json_package": JSON.stringify({
		            "head": {},
		            "body": {"file": "file"}
		        })
		    },
		    name: 'file',
		    onSubmit: function (file, ext) {
		        window.uploading = true;
		        $('#photoUpload_4').text('上传中...');
		        $('#photoUpload_4').attr('disabled', true);
		        this.disable();
		
		    },
		    onChange: function (file, extension) {
		        this.disable();
		    },
		    onComplete: function (file, response) {
		    	var data = JSON.parse(response);

		    	var result = data.body.result;
				var description = data.body.description;
				if(result == "1"){
					alert("图片太大");
					window.uploading = false;
					this.enable();
					return;
				}
				
				var fileUrl = data.body.fileUrl;
				
		    	$("#image4").attr('src',fileUrl); 
		        window.uploading = false;
		        $('#photoUpload_4').text('上传图片');
		        this.enable();
		    }
		});
	})();
    (function(){
		var ajaxUpload = new AjaxUpload($('#photoUpload_5'), {
		    action: '${webPath}/file/uploadImage',
		    data: {
		        "json_package": JSON.stringify({
		            "head": {},
		            "body": {"file": "file"}
		        })
		    },
		    name: 'file',
		    onSubmit: function (file, ext) {
		        window.uploading = true;
		        $('#photoUpload_5').text('上传中...');
		        $('#photoUpload_5').attr('disabled', true);
		        this.disable();
		
		    },
		    onChange: function (file, extension) {
		        this.disable();
		    },
		    onComplete: function (file, response) {
		    	var data = JSON.parse(response);

		    	var result = data.body.result;
				var description = data.body.description;
				if(result == "1"){
					alert("图片太大");
					window.uploading = false;
					this.enable();
					return;
				}
				
				var fileUrl = data.body.fileUrl;
				
		    	$("#image5").attr('src',fileUrl); 
		        window.uploading = false;
		        $('#photoUpload_5').text('上传图片');
		        this.enable();
		    }
		}); 
	})();*/
</script>
</body>
</html>